﻿Public Class Mitarbeiter
    Inherits Base

    Public vorname As String
    Public nachname As String
    Public passwort As String
    Public stundenansatz As Double

    Public Function getNiceName() As String
        Return firstUpper(Me.vorname) & " " & firstUpper(Me.nachname)
    End Function

    Private Function firstUpper(ByVal text As String) As String
        If text.Length = 0 Then
            Return ""
        End If
        If text.Length = 1 Then
            Return text.ToUpper()
        End If
        Return text.Substring(0, 1).ToUpper() & text.Substring(1)
    End Function

    Public Overrides Sub validate()
        If isEmptyString(vorname) Then
            Throw New Exception("Vorname ist leer.")
        End If
        If isEmptyString(nachname) Then
            Throw New Exception("Nachname ist leer.")
        End If
        If isEmptyString(passwort) Then
            Throw New Exception("Passwort ist leer.")
        End If
        If stundenansatz < 0 Then
            Throw New Exception("Stundenlohn kann nicht kleiner 0 sein.")
        End If
    End Sub
End Class
